package com.rd.student.jike.class2.lihongming.week731_806.Day0803.Pet;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @Auther:Heinrich
 * @Date:2023/8/2-08-02-14:23
 * @Description:c230802
 * @version:1.0
 */
public class Store {
    public static Animal getInstance(String type, String name, String chara) {
        if (type.equals("dog")) {
            return new Dog(name, chara);
        } else if (type.equals("pig")) {
            return new Pig(name);
        } else {
            return new Cat(name, chara);
        }
    }
    public static Animal getInstance(){
        ArrayList<Animal> list = new ArrayList<>();
        String[] strName = {"二黑","雪顶咖啡","橘子","三黑","大黑","拉姆","老白","粽子","白白","四黑","蓝莓","柠檬","草莓","苹果","香蕉","蓝宝石","玛瑙","珍珠","云母","花岗岩"};
        String[] dogCharaName= {"白色","黑白花","棕色","黑色","金色","银色","金棕色"};
        String[] catCharaName = {"蓝色","黑色","金色","绿色","紫色","浅蓝色","棕色","明黄色"};
        for (int i = 0; i < 18; i++) {
            if(i<10){
                list.add(getInstance("dog",randomStr(strName),randomStr(dogCharaName)));
            }else if(i<15){
                list.add(getInstance("cat",randomStr(strName),randomStr(catCharaName)));
            }else{
                list.add(getInstance("pig",randomStr(strName),""));
            }
        }        
       return list.get((int) (Math.random()*list.size()));
    }
    public static Animal getInstance(String Type,int Num){
        ArrayList<Animal> list = new ArrayList<>();
        String[] strName = {"二黑","雪顶咖啡","橘子","三黑","大黑","拉姆","老白","粽子","白白","四黑","蓝莓","柠檬","草莓","苹果","香蕉","蓝宝石","玛瑙","珍珠","云母","花岗岩"};
        String[] dogCharaName= {"白色","黑白花","棕色","黑色","金色","银色","金棕色"};
        String[] catCharaName = {"蓝色","黑色","金色","绿色","紫色","浅蓝色","棕色","明黄色"};
        for (int i = 0; i < Num; i++) {
            if(Type.equals("dog")){
                list.add(getInstance(Type,randomStr(strName),randomStr(dogCharaName)));
            } else if (Type.equals("pig")) {
                list.add(getInstance(Type,randomStr(strName),""));
            }else{
                list.add(getInstance(Type,randomStr(strName),randomStr(catCharaName)));
            }
            System.out.println((i+1)+"."+list.get(i).toString());
        }
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您选择第几只宠物（随便请输入0）");
        int sc = scanner.nextInt()-1;
        if(sc == -1){
            return list.get((int) (Math.random()*list.size()));
        }
        return list.get(sc);
    }

    public static String randomStr(String[] strs){
        return strs[(int) (Math.random()*strs.length)];
    }
}
